/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package casino;

/**
 * Class for a non-random number generator to be used in unit testing of the
 * wheel class. Set a sequence of integer items, then run so that it returns 
 * the next item on the sequence and keeps repeating the last item for the remaining
 * 50 samples. Repeat all this again.
 *
 * @author  amaghfur
 * @since   1.0
 */
public class NonRandom extends java.util.Random {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/** the sequence of values when using the sequencer */
    private int sequence[];
    /** keeps track of which sequence number to return next */
    private int seqIndex = 0;
    
    /**
     * Constructor for this class.
     */
    public NonRandom(int setSequence[]) {
        sequence = setSequence;
    }
    
    
    /**
     * Setter for sequence.
     * 
     * @param newSequence 
     */
    public void setSequence(int setSequence[]) {
        sequence = setSequence;
    }
    
    /**
     * Returns next item on the sequence then keeps repeating the last item for the remaining
     * 50 samples, then repeat the sequence again.
     * 
     * @return  next number in sequence
     */
    @Override
    public int nextInt(int dummy) {
        if (seqIndex < sequence.length) {
            seqIndex++;
            return sequence[seqIndex-1];
        }
        else {
            seqIndex++;
            if (seqIndex == 50)
                seqIndex = 0; // reset the seqIndex to begin repeating the sequence again
            return sequence[sequence.length-1];
        }
    }

}
